package wang.lx.mybatis.common;

import lombok.Data;

/**
 * @Description: 响应消息
 * @Author: 王的世界
 * @Date: 20250707
 */
@Data
public class ResponseMessage<T> {
    private int code;
    private String msg;
    private T data;

    public ResponseMessage(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResponseMessage<T> success(T data)
    {
        return new ResponseMessage<T>(200, "ok", data);
    }

    public static <T> ResponseMessage<T> error(T data)
    {
        return new ResponseMessage<T>(500, "操作失败", data);
    }
    public static <T> ResponseMessage<T> error(T data,String msg)
    {
        return new ResponseMessage<T>(500, msg==null?"error":msg, data);
    }
    
}
